$.fn.sCaption = function(options){
	this.each(function(){
		var defaults = {
			backgroundColor: '#000000',
			opacity: 60,
			shadow: true,
			shadowColor: '#000000',
			shadowDisplacement: 2,
			margin: 10,
			fontFamily: 'arial',
			fontSize: '10px',
			fontWeight: 'normal',
			fontColor: '#ffffff'
		};
		
		var opts = $.extend(defaults, options);
		
		var wrapper=$(this);
		var img=wrapper.children('img');
		var link=wrapper.children('a');
		var span=wrapper.children('span');
		var innerTxt='';
		
		wrapper.css('position','relative');
		wrapper.css('width',img.width()+'px');
		wrapper.css('height',img.height()+'px');
		
		if (link.html() || link.attr('href')!=undefined)
			{
			link.css('display','block');
			link.css('position','absolute');
			link.css('top','0px');
			link.css('left','0px');
			link.css('width',img.width()+'px');
			link.css('height',img.height()+'px');
			link.css('background-image','url(\'transparent.gif\')');
			link.css('z-index','4');
			innerTxt=link.html();
			link.html('');
			}
		else
			{
			innerTxt=span.html();
			span.remove();
			}
		
		if($.trim(innerTxt)!='')
			{
			img.after('<div class="sCaptionedText">'+innerTxt+'</div>');
			var text=img.next('.sCaptionedText');
			text.css('position','absolute');
			text.css('display','block');
			text.css('width',(img.width()-(opts.margin*2))+'px');
			text.css('font-family',opts.fontFamily);
			text.css('font-size',opts.fontSize);
			text.css('font-weight',opts.fontWeight);
			text.css('color',opts.fontColor);
			text.css('bottom',opts.margin+'px');
			text.css('left',opts.margin+'px');
			text.css('z-index','3');
			
			text.after('<div class="sCaptionedShadow">'+innerTxt+'</div>');
			var shadow=text.next('.sCaptionedShadow');
			shadow.css('position','absolute');
			shadow.css('display','block');
			shadow.css('width',(img.width()-(opts.margin*2))+'px');
			shadow.css('font-family',opts.fontFamily);
			shadow.css('font-size',opts.fontSize);
			shadow.css('font-weight',opts.fontWeight);
			shadow.css('color',opts.fontColor);
			shadow.css('color',opts.shadowColor);
			shadow.css('left',text.position().left+opts.shadowDisplacement+'px');
			shadow.css('top',text.position().top+opts.shadowDisplacement+'px');
			shadow.css('z-index','2');
			
			shadow.children('img').css('visibility','hidden');
			
			shadow.after('<div class="sCaptionedBackground"/>');
			var background=shadow.next('.sCaptionedBackground');
			background.css('position','absolute');
			background.css('width',img.width()+'px');
			background.css('height',text.height()+opts.margin*2+'px');
			background.css('background-color',opts.backgroundColor);
			background.css('top',(img.height()-text.height()-opts.margin*2)+'px');
			background.css('left','0px');
			background.css('opacity',opts.opacity/100);
			background.css('filter','alpha(opacity='+opts.opacity+')');
			background.css('z-index','1');
			}
		wrapper.css('visibility','visible');
	  });
  };